﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;


using Castle.Core.Interceptor;
using Castle.DynamicProxy;



namespace DynamicProxyExample
{

    class Program
    {

        static void Main(string[] args)
        {

            ProxyGenerator generator = new ProxyGenerator();

            Logger logger = generator.CreateClassProxy<Logger>(new TestInterceptor());

            logger.Write("World.");

        }

    }



    public class TestInterceptor : IInterceptor
    {

        public void Intercept(IInvocation invocation)
        {
            
            Console.Write("Hello, ");

            invocation.Proceed();

        }

    }



    public class Logger
    {

        public virtual void Write(string message)
        {

            Console.Write(message);

        }

    }

}



